﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Ulriksen.Umbraco.OpenId.Web
{
    public partial class AttachedOpenId : System.Web.UI.UserControl
    {
        private string openId;

        public string OpenId
        {
            get { return openId; }
            set { openId = value; }
        }

        private bool readOnly;

        public bool ReadOnly
        {
            get { return readOnly; }
            set { readOnly = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(OpenId))
                OpenId = Label1.Text;

            
                   
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (Label1 == null)
                Label1 = new Label();
            Label1.Text = OpenId;

            if (ReadOnly)
                deleteOpenId.Visible = false;
        }

        protected void deleteOpenId_Click(object sender, EventArgs e)
        {
            Ulriksen.Umbraco.OpenId.OpenIdMember.RemoveOpenId(this.openId);
            this.Parent.Controls.Remove(this);
        }

        public AttachedOpenId()
        {

        }
        public AttachedOpenId(string openId)
        {
            OpenId = openId;
        }

    
    }
}